package com.gosophia.govDoc.action.turning;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.dataDictionary.dto.DataValueDTO;
import com.gosophia.dataDictionary.ws.DataDictionaryWebService;
import com.gosophia.govDoc.common.DocumentJobType;
import com.gosophia.govDoc.dto.DocumentJobDataDTO;
import com.gosophia.govDoc.ws.DocumentTurningWebService;
import com.gosophia.taskManagement.dto.JobDTO;
import com.gosophia.taskManagement.dto.MissionDTO;
import com.gosophia.taskManagement.ws.TaskManagementWebService;

@SuppressWarnings("serial")
@Scope("prototype")
@Controller("GetDocumentJobDataAction")
public class GetDocumentJobDataAction extends BaseSupportAction {

    private final Logger logger = Logger.getLogger(this.getClass());

    /** 进入处理页面标识：审批页面： approve； 修改页面：modify */
    private String dealFlag;

    private List<DataValueDTO> dataValueList;

    private Long jobId;

    private DocumentJobDataDTO detailData;

    @Autowired
    private DataDictionaryWebService dataDictionaryWebService;

    @Autowired
    private DocumentTurningWebService documentTurningWebService;

    @Autowired
    private TaskManagementWebService taskManagementWebService;

    private MissionDTO missionDto;

    @Override
    public String _execute() throws Exception {
        detailData = documentTurningWebService
                .findDocumentJobDataByJobId(jobId);

        if (detailData.getJobDTO().getJobType().equals(
                DocumentJobType.simulate.toString())) {
            dataValueList = dataDictionaryWebService
                    .findEnabledDataValueByEntryName("zhongyaochengdu");// 任务重要程度
            JobDTO jobDTO = taskManagementWebService
                    .findJobDetailByJobId(jobId);
            missionDto = jobDTO.getMissionDTO();
            return "Simulate";
        }
        if (detailData.getJobDTO().getJobType().equals(
                DocumentJobType.approve.toString())) {
            dealFlag = "approve";
            return SUCCESS;// 进入任务审批页面标识
        } else {
            dealFlag = "modify";
            return SUCCESS;// 进入任务修改页面标识
        }
    }

    public void setJobId(Long jobId) {
        this.jobId = jobId;
    }

    public Long getJobId() {
        return jobId;
    }

    public DocumentJobDataDTO getDetailData() {
        return detailData;
    }

    public void setDetailData(DocumentJobDataDTO detailData) {
        this.detailData = detailData;
    }

    public void setDataValueList(List<DataValueDTO> dataValueList) {
        this.dataValueList = dataValueList;
    }

    public List<DataValueDTO> getDataValueList() {
        return dataValueList;
    }

    public MissionDTO getMissionDto() {
        return missionDto;
    }

    public void setMissionDto(MissionDTO missionDto) {
        this.missionDto = missionDto;
    }

    public void setDealFlag(String dealFlag) {
        this.dealFlag = dealFlag;
    }

    public String getDealFlag() {
        return dealFlag;
    }

}
